#!/bin/bash
# init centos7  ./kubernetes-initmaster-6.sh

name=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | awk -F"/" '{print $1}')

startup(){
 echo $name
   kubeadm init \
  --apiserver-advertise-address=$name \
  --image-repository registry.aliyuncs.com/google_containers \
  --kubernetes-version v1.15.1 \
  --pod-network-cidr=10.244.0.0/16 | tee kubeadm-init.log

}

chownPermition(){
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
}


main(){
  startup
  chownPermition
}
main
